Repository navigation
Preserve remote post languages from contentMap - #659
Conversation
Mastodon and Hollo send content together with contentMap, so after JSON-LD expansion the content property holds both a plain string and a language-tagged one. persistPost() only looked at the singular object.content and object.summary accessors, which return the plain string, so the language of such posts was always stored as null. The language is now taken from the first LanguageString found among all content values, then all summary values. Values tagged as undetermined (und), which a context-level default @language such as Pleroma's produces, are skipped so that they don't shadow the real language in contentMap. Fixes fedify-dev#647 Assisted-by: Claude Code:claude-opus-5-5 Assisted-by: Claude Code:claude-fable-5-1
Fedify 2.2.16 normalizes BCP 47 extended language subtags before handing language tags to Intl.Locale. Mastodon tags Cantonese posts as zh-YUE, which is a valid BCP 47 tag but not a valid Unicode locale identifier, so Fedify used to drop such language-tagged strings and Hollo stored no language for those posts. They are now kept with the canonical tag yue. fedify-dev#647 fedify-dev/fedify#1229 Assisted-by: Claude Code:claude-opus-5-5
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughRemote post persistence now selects language metadata from language-tagged content or summaries. The change also upgrades Fedify dependencies to 2.2.16 and adds tests for language-map selection and language-tag canonicalization. ChangesRemote post language preservation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The language-selection change is implemented as intended, and no current user-facing failure is established. A test for conflicting content and summary languages would be a useful non-blocking improvement. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 3 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (2 skipped: 2 unsupported.)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #647.
Mastodon and Hollo send
contenttogether withcontentMap. After JSON-LD expansion, thecontentproperty holds both values, with the plain string first.persistPost()read only the singularobject.content, so it never saw theLanguageStringand storednullas every remote post's language.getLanguage()in src/federation/post.ts scanscontents, thensummaries, for the first language-tagged value. It skipsundbecause a default@languagein the sender's@contexttags the plaincontenttoo, which would otherwise hide the language fromcontentMap. A missinglocale.languagecounts asundas well, since Node.js 24 returnsundefinedfornew Intl.Locale("und").language.The tests in src/federation/post.test.ts use
Note.fromJsonLd()to get the value order that triggers the bug. ANotebuilt with the constructor keeps whatever order you give it.The second commit upgrades Fedify to 2.2.16, which normalizes Mastodon's Cantonese tag
zh-YUEtoyue(fedify-dev/fedify#1229).zh-YUEis valid BCP 47, butIntl.Localerejects it, so earlier versions dropped the value. I kept the upgrade in its own commit so it can be reviewed or reverted separately.Summary by CodeRabbit
zh-YUE.